// is 用来描述函数的返回值类型

class Student {
  isStudent(): this is Student {
    return true;
  }
}

type Dog = {
  bar(): void;
};

type Cat = {
  eat(): void;
};

type Animal = Dog | Cat;

function ShowDogName(an: Animal): an is Dog {
  const isDog = an as Dog;
  console.log(isDog);
  return !!isDog.bar;
}

const cat = {
  eat() {
    console.log("cat is eat");
    const ms = 1333;
  },
};

const dog = {
  bar() {
    console.log("dog is bar");
  },
};

// const isDog = ShowDogName(cat);
const isDog2 = ShowDogName(dog);
